package cn.iocoder.yudao.adminserver.modules.fi.convert.project;

import cn.iocoder.yudao.adminserver.modules.fi.controller.project.vo.ProjectCreateReqVO;
import cn.iocoder.yudao.adminserver.modules.fi.controller.project.vo.ProjectExcelVO;
import cn.iocoder.yudao.adminserver.modules.fi.controller.project.vo.ProjectRespVO;
import cn.iocoder.yudao.adminserver.modules.fi.controller.project.vo.ProjectUpdateReqVO;
import cn.iocoder.yudao.adminserver.modules.fi.dal.dataobject.project.ProjectDO;
import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user.SysUserDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;
import java.util.Map;


/**
 * 项目管理 Convert
 *
 * @author hickTeam
 */
@Mapper
public interface ProjectConvert {

    ProjectConvert INSTANCE = Mappers.getMapper(ProjectConvert.class);

    ProjectDO convert(ProjectCreateReqVO bean);

    ProjectDO convert(ProjectUpdateReqVO bean);

   default ProjectRespVO convert(ProjectDO bean, Map<Long, SysUserDO> userMap){
       if ( bean == null ) {
           return null;
       }
       ProjectRespVO projectRespVO = new ProjectRespVO();
       projectRespVO.setId( bean.getId() );
       projectRespVO.setProjectName( bean.getProjectName() );
       projectRespVO.setProjectDesc( bean.getProjectDesc() );
       projectRespVO.setAddress( bean.getAddress() );
       projectRespVO.setAreaManagerUid( bean.getAreaManagerUid() );
       projectRespVO.setProjectLeaderUid( bean.getProjectLeaderUid() );
       projectRespVO.setImgList( bean.getImgList() );
       projectRespVO.setThirdName( bean.getThirdName() );
       projectRespVO.setDirectorUid( bean.getDirectorUid() );
       projectRespVO.setIsNormal( bean.getIsNormal() );
       projectRespVO.setCaptainUid( bean.getCaptainUid() );
       projectRespVO.setCreateTime( bean.getCreateTime() );
       projectRespVO.setUpdateTime( bean.getUpdateTime() );
       projectRespVO.setIsFinish( bean.getIsFinish() );
       SysUserDO user = userMap.get(bean.getCreator());
       projectRespVO.setCreator(user == null ? "" : user.getNickname());
       //projectRespVO.setCreator( bean.getCreator() );
       user = userMap.get(bean.getAreaManagerUid());
       projectRespVO.setAreaManagerName(user == null ? "" : user.getNickname());
       user = userMap.get(bean.getProjectLeaderUid());
       projectRespVO.setProjectLeaderName(user == null ? "" : user.getNickname());
       user = userMap.get(bean.getDirectorUid());
       projectRespVO.setDirectorName(user == null ? "" : user.getNickname());
       return projectRespVO;
   }

    List<ProjectRespVO> convertList(List<ProjectDO> list);

    PageResult<ProjectRespVO> convertPage(PageResult<ProjectDO> page);

    List<ProjectExcelVO> convertList02(List<ProjectDO> list);

}
